package com.qyc.controller;

import com.qyc.dto.AddOrUpDateDiseaseRecordDTO;
import com.qyc.service.DiseaseRecordService;
import com.qyc.service.DiseaseService;
import com.qyc.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: DiseaseController
 * @Description: 病症记录管理相关Controller层
 * @author: qinyc
 * @date: 2023/6/26 11:50
 * @version: v1.0
 */
@Api(tags = "病症管理")
@RestController
@RequestMapping("/diseaseRecord")
public class DiseaseController {
    //注入病症管理Service层对象
    @Autowired
    private DiseaseService diseaseService;

    //注入病症记录Service层对象
    @Autowired
    private DiseaseRecordService diseaseRecordService;
    
    /**
     * @Author qinyc
     * @Description 查询所有病症类型信息
     * @version: v1.0
     * @Date 11:52 2023/6/26
     **/
    @ApiOperation("查询所有病症类型信息")
    @GetMapping("/queryAllDisease")
    public ResponseResult queryAllDisease(){
        return diseaseService.queryAllDisease();
    }

    /**
     * @Author qinyc
     * @Description  分页多条件查询病症记录
     * @version: v1.0
     * @Date 12:05 2023/6/26
     **/
    @ApiOperation("分页多条件查询病症记录")
    @GetMapping("/query")
    public ResponseResult queryPage(Integer pageNum,Integer pageSize,String drDId,String drStatus){
        return diseaseService.queryPage(pageNum,pageSize,drDId,drStatus);
    }
    
    /**
     * @Author qinyc
     * @Description  新增或更新病症记录
     * @version: v1.0
     * @Date 12:47 2023/6/26
     **/
    @ApiOperation("新增或更新病症记录")
    @PostMapping("/saveOrUpdate")
    public ResponseResult saveOrUpdate(@RequestBody AddOrUpDateDiseaseRecordDTO addOrUpDateDiseaseRecordDTO){
        return diseaseRecordService.saveOrUpdate(addOrUpDateDiseaseRecordDTO);
    }
    
    /**
     * @Author qinyc
     * @Description  根据记录ID删除病症记录
     * @version: v1.0
     * @Date 13:30 2023/6/26
     **/
    @ApiOperation("根据记录ID删除病症记录")
    @DeleteMapping("/deleteById/{drId}")
    public ResponseResult deleteById(@PathVariable("drId") Integer drId){
        return diseaseRecordService.deleteById(drId);
    }

    /**
     * @Author qinyc
     * @Description  批量删除病症记录
     * @version: v1.0
     * @Date 13:39 2023/6/26
     **/
    @ApiOperation("批量删除病症记录")
    @DeleteMapping("/deleteByIdAll")
    public ResponseResult deleteByIdAll(@RequestBody List<Integer> drIds){
        return diseaseRecordService.deleteByIdAll(drIds);
    }
}
